/**************************************************************************************************
* Title: SumKeyboard.h
* Author: Gael Huber
* Description: Manages calls to get the keyboard state and tracks changes between calls.
**************************************************************************************************/
#ifndef __SUMKEYBOARD_H__
#define __SUMKEYBOARD_H__

#ifndef DIRECTINPUT_VERSION
#define DIRECTINPUT_VERSION 0x0800
#endif

#include <dinput.h>
#include "SumGlobals.h"

class Keyboard {
public:
	// Constructors and destructors
	Keyboard(void);
	Keyboard(LPDIRECTINPUT8 input);
	~Keyboard(void);

	void update(void);	// Updates the keyboard state
	int getKeyPressed(int code) const;		// Returns whether a given key is being pressed

private:
	LPDIRECTINPUTDEVICE8 keyboard;	// Pointer to the keyboard device
	BYTE keyState[256];		// Current keyboard state
	BYTE prevKeyState[256];	// Previous keyboard state
};

// TODO: Move this to inl file later
inline int Keyboard::getKeyPressed(int code) const {
	return (keyState[code] & 0x80);
}

#endif